import Vue from 'vue'
import Vuex from 'vuex'
// 引入接口函数
import { getimgtext } from '../api/index'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    textimgimfo: JSON.parse(localStorage.getItem('updateimge')) || []
  },
  mutations: {
    UPDATAIMGTEXT (state, textimg) {
      state.textimgimfo = textimg
    }
  },
  actions: {
    async updatagetimgtext (context, file) {
      const result = await getimgtext(file)
      // 存储在vuex
      localStorage.setItem('updateimge', JSON.stringify(result.data))
      // 修改mutations
      context.commit('UPDATAIMGTEXT', result.data)
    }
  },
  modules: {
  }
})
